package com.chaosj.tools.rules

import com.chaosj.tools.StockDiscoverTools
import com.chaosj.tools.traits.TraitRule

class BaseUpDownRule implements IAbnormalRule, TraitRule {
    @Override
    boolean execute(String stockName, List<StockDiscoverTools.DescriptionStock> stocks) {
        int index = stocks.size() - 1
        if( upUp(index-1,stocks,checkDay()) ){
            println(description(stockName,checkDay()+"","红"))
            return true
        }
        if( downDown(index-1,stocks,checkDay()) ){
            println(description(stockName,checkDay()+"","绿"))
            return true
        }
        return false
    }

    @Override
    boolean support(String stockName, List<StockDiscoverTools.DescriptionStock> stocks) {
        return stocks.size()>=4
    }

    @Override
    String description(Object... desc) {
        return String.format("【%s】连续[%s]天收%s,请及时跟进可能有一波大涨",desc)
    }

    int checkDay(){
        3
    }
}
